import request from '@/utils/request'

/**
 * 修改个人信息
 * @param gender
 * @param nickName
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const setMyInfo = ({ gender, nickName }) =>
  request.put('/api/users/setMyInfo', { gender, nickName })

/**
 * 修改密码
 * @param phone
 * @param code
 * @param password
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const smsSetPassword = ({ phone, smsCode, password }) =>
  request.post('/auth/smsSetPassword', { phone, smsCode, password })

/**
 * 发送修改密码短信验证码
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const sendSetPasswordSmsCode = () => request.post('/auth/sendSetPasswordSmsCode')
/**
 * 短信验证登录
 * @param phone
 * @param code
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userSmsLogin = ({ phone, code }) =>
  request.post('/auth/smsLogin', {
    phone,
    smsCode: code
  })

/**
 * 发送短信验证码
 * @param phone
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userGetLoginCode = ({ phone }) => request.post('/auth/sendSmsCode', { phone })

/**
 * 登录接口
 * @param username
 * @param password
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userLoginService = ({ username, password }) =>
  request.post('/auth/login', { username, password })

/**
 * 获取用户基本信息
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userGetInfoService = () => request.get('/auth/info')

/**
 * 退出登录
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const userLogoutService = () => request.delete('/auth/logout')
